package models;

import com.et.ar.ActiveRecordBase;
import com.et.ar.annotations.BelongsTo;
import com.et.ar.annotations.Column;
import com.et.ar.annotations.Id;
import com.et.ar.annotations.Table;
import com.et.ar.annotations.Unique;

import java.sql.*;


@Table(name="banners")
public class Banner extends ActiveRecordBase{
	@Id private Integer id;
	@Column private String title;
	@Column private Integer btype;
	@Column private Integer iheight;
	@Column private String fileid;
    @Column private Integer sort;
    @Column private Integer status;
    @Column private String link;
    
    public String getImgheight(){
    	if (iheight == 0) 
    		return "100%";
    	else
    		return iheight.toString() + "px";
    }
	//	@BelongsTo(foreignKey="demoId")
	//	private Demo demo;

	//	public Demo getDemo() {
	//		return demo;
	//	}
	//	public void setDemo(Demo demo) {
	//		this.demo = demo;
	//	}

	//	public int getChildCount() throws Exception {
	//		return (int)count(Banner.class, "parentId=?", new Object[]{id});
	//	}
	//	public String findChildIds() throws Exception {
	//		String s = "";
	//		List<Integer> ids = new ArrayList<Integer>();
	//		ids.add(id);
	//		while(!ids.isEmpty()){
	//			int id = ids.remove(0);
	//			s += id + ",";
	//			for(Banner item: Banner.findAll(Banner.class, "parentId=?", new Object[]{id})){
	//				ids.add(item.getId());
	//			}
	//		}
	//		if (!s.equals("")){
	//			s = s.substring(0, s.length() - 1);
	//		}
	//		return s;
	//	}
	public void setId(Integer id){
		this.id=id;
	}
	public Integer getId(){
		return id;
	}

	public void setTitle(String title){
		this.title=title;
	}
	public String getTitle(){
		return title;
	}

	public void setBtype(Integer btype){
		this.btype=btype;
	}
	public Integer getBtype(){
		return btype;
	}

	public void setIheight(Integer iheight){
		this.iheight=iheight;
	}
	public Integer getIheight(){
		return iheight;
	}

	public void setFileid(String fileid){
		this.fileid=fileid;
	}
	public String getFileid(){
		return fileid;
	}

    public void setSort(Integer sort){
		this.sort=sort;
	}
	public Integer getSort(){
		return sort;
	}
	
	public void setStatus(Integer status){
		this.status=status;
	}
	public Integer getStatus(){
		return status;
	}
	
	public void setLink(String link){
		this.link=link;
	}
	public String getLink(){
		return link;
	}
}

